DECLARE @TRANSACTIONS TABLE (Line INT, Amt MONEY)
INSERT INTO @TRANSACTIONS (Line, Amt) VALUES (1,$70.00), (2,$20.00), (3,$90.00)

DECLARE @TOTALAVAILABLE MONEY = $-10

;WITH
RunningTotals AS
(
	SELECT
		T.Line,
		T.Amt,
		(SELECT SUM(Amt) FROM @TRANSACTIONS AS T2 WHERE T2.Line <= T.Line) AS RunningTotal 
	FROM
		@TRANSACTIONS AS T
),
LinePaidSum AS
(
	SELECT
		@TOTALAVAILABLE - SUM(Amt) AS Balance,
		MAX(Line) + 1 AS LineToApplyBalance
	FROM
		RunningTotals
	WHERE
		RunningTotal <= @TOTALAVAILABLE
)
SELECT 
	 RT.Line,
	 RT.Amt,
	 CASE
		WHEN RT.RunningTotal <= @TOTALAVAILABLE THEN RT.Amt
		WHEN @TOTALAVAILABLE < RT.Amt AND @TOTALAVAILABLE < RT.RunningTotal AND RT.Line = 1 THEN @TOTALAVAILABLE
		WHEN LineToApplyBalance IS NOT NULL AND Balance > 0 THEN Balance
		ELSE $0.00
	 END AS AmountToApply
FROM 
	RunningTotals AS RT
	LEFT JOIN LinePaidSum AS LP ON (RT.Line = LP.LineToApplyBalance)